<template>
	<div>
		<el-row>
			<el-col :span="24">
				<el-form :model="formData" ref="formDataRef" :rules="rules" label-width="100px">
					<el-form-item label="类别:">
						<el-select v-model="formData.BankType" prop="BankType" style="width: 100%;" filterable>
							<el-option :value="0" label="银行卡"></el-option>
							<!-- <el-option :value="1" label="现金"></el-option> -->
						</el-select>
					</el-form-item>		
<!-- 					<el-form-item label="初始额度:" prop="InitPrice">
						<el-input placeholder="请输入初始额度" v-model.number="formData.InitPrice"></el-input>
					</el-form-item>		 -->						
					<el-form-item label="开户行:" prop="BankName" v-if="formData.BankType == 0">
						<el-input placeholder="请输入开户行" v-model="formData.BankName"></el-input>
					</el-form-item>
					<el-form-item label="银行卡号:" prop="BankNumber" v-if="formData.BankType == 0">
						<el-input placeholder="请输入银行卡号" v-model="formData.BankNumber"></el-input>
					</el-form-item>
					<el-form-item align="right">
						<el-button type="primary" style="width: 100%;" @click="insertHandler">保存</el-button>
					</el-form-item>
				</el-form>
			</el-col>
		</el-row>
	</div>
</template>

<script>
	export default {
		props: {
			closeFun: {
				type: Function,
				required: true
			},
			updata:{
				type: Object,
				required: true
			}
		},
		watch:{
			updata:{
				handler(value){ 
					this.formData = { ...value }
				},
				immediate: true,
				deep: true,
			}
		},
		data() {
			return {
				formData: {},
				rules: {
					// BankName: [{
					// 	required: true,
					// 	message: '请输入开户行名称',
					// 	trigger: 'blur'
					// }],
					// BankNumber: [{
					// 	required: true,
					// 	message: '请输入银行卡编号',
					// 	trigger: 'blur'
					// }],
					// InitPrice: [{
					// 	type: 'number',
					// 	required: true,
					// 	message: '请输入初始额度',
					// 	trigger: 'blur'
					// }],
					BankType: [{
						required: true,
						message: '请选择类型',
						trigger: 'change'
					}],
				},
			}
		},
		methods: {
			insertHandler() {
				this.$refs.formDataRef.validate(valid => {
					if (valid) {
						this.$http.post('/api/Bankinfo/Update/update', this.formData).then(res => {
							const {
								StatusCode,
								Data,
								Message
							} = res.data || 0
							if (StatusCode == 200) {
								this.$message.success('修改成功')
								this.resetFieldsEvent()
								this.$parent.$parent.dialogUpdataForm.show = false
								this.closeFun()
							} else {
								this.$message.warning(Message)
							}
						})
					}
				})
			},
			resetFieldsEvent(){
				this.$refs.formDataRef.resetFields()
			}
		}
	}
</script>

<style>
</style>